package map01;

import java.util.HashMap;
/*
* Map体系的双大括号初始化
*   本质是匿名内部类+构造代码块
*         HashMap<Integer, String> hm = new HashMap<>(){{
*          put(123, "老王");
*          put(456, "小李");
*          put(789, "老张");
*     }};
*
*     相当于:
*     class HashMap$1 extends HashMap<Integer,String>{
*          //构造代码块
*          {
*             //put方法依然使用的是HashMap中的
*             put(123, "张三");
*             put(456, "小明");
*             put(789, "老王");
*          }
*
*     }
*    HashMap<Integer, String> hm =  new HashMap$1();
*
* */
public class HashMapDemo03 {
    public static void main(String[] args) {
        HashMap<Integer, String> hm = new HashMap<>(){{
            put(123, "老王");
            put(456, "小李");
            put(789, "老张");
        }};

        System.out.println(hm);
    }
}
